﻿namespace Website.Views.PageTitle
{
    using System;
    using System.Net;
    using System.Web.Mvc;

    using Website.Models;

    public partial class HtmlRepresentation : ViewPage<WikiPage>
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!WikiPage.IsValidTitle(this.ViewData.Model.Title))
            {
                this.Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
            else if (!this.ViewData.Model.LastModified.HasValue || this.ViewData.Model.Removed.HasValue)
            {
                this.Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
            else
            {
                this.Response.StatusCode = (int)HttpStatusCode.OK;
            }
        }
    }
}